/*
 *  Copyright 2015-2016, RenGu Technology (BeiJing) Co., Ltd.
 *  All right reserved.
 *
 *  THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF RENGU TECHNOLOGY (BeiJing) CO., LTD.
 *
 *  THE CONTENTS OF THIS FILE MAY NOT BE DISCLOSED TO THIR PARTIES,
 *  COPIED OR DUPLICATED IN ANY FORM, IN WHOLE OR IN PART,
 *  WITHOUT THE PRIOR WRITTEN PERMISSION OF RENGU TECHNOLOGY (BeiJing) CO., LTD.
 *
 *  AcctTxnNumEnum
 *
 *  Edit History:
 *      lizhangtao Created on 2020年05月15日
 *
 */
package cc.rengu.igas.acct.common.enums;

/**
 * 虚拟账户交易及服务枚举
 *
 * @author lizhangtao
 * @version 1.0
 * @date 2020/5/15
 */
public enum AcctTxnNumEnum {
    /**
     * 开户
     */
    ESTABLISH("M00AT001", "VirtAcctEstablishService", "开户"),
    /**
     * 余额查询
     */
    BALANCE_QUERY("T00AT001", "VirtAcctBalanceQueryService", "余额查询"),
    /**
     * 周期内交易明细查询
     */
    TRANS_DETAIL_QUERY("T00AT002", "VirtAcctTransDetailQueryService", "周期内交易明细查询"),
    /**
     * 单笔交易明细查询
     */
    SINGLE_TRANS_DETAIL("T00AT003", "VirtAcctSingleTransDetailQueryService", "单笔交易明细查询"),
    /**
     * 预授权
     */
    PRE_AUTH("P06AT100", "VirtAcctPreAuthService", "预授权"),
    /**
     * 预授权撤销
     */
    PRE_AUTH_CANCEL("P06AT300", "VirtAcctPreAuthCancelService", "预授权撤销"),
    /**
     * 预授权完成
     */
    PRE_AUTH_COMP("P06AT500", "VirtAcctPreAuthCompleteService", "预授权完成"),
    /**
     * 单笔记账
     */
    SINGLE_ADJUST("P01AT001", "VirtAcctSingleAdjustService", "单笔记账"),
    /**
     * 状态修改
     */
    STATUS_CHANGE("M00AT002", "VirtAcctStatusChangeService", "状态修改"),
    /**
     * 多商户记账
     */
    MULTI_MCHNT_ADJUST("P01AT002", "VirtAcctMultiMchntAdjustService", "多商户记账"),
    /**
     * 记账状态查询
     */
    TRANS_STATUS_QUERY("T00AT004", "VirtAcctTransStatusQueryService", "记账状态查询"),
    /**
     * 多商户预授权
     */
    MULT_MCHNT_PRE_AUTH("P06AT101", "VirtAcctMultiMchntPreAuthService", "多商户预授权"),
    /**
     * 多商户预授权撤销
     */
    MULT_MCHNT_PRE_AUTH_CANCEL("P06AT301", "VirtAcctMultiMchntPreAuthCancelService", "多商户预授权撤销"),
    /**
     * 多商户预授权完成
     */
    MULT_MCHNT_PRE_AUTH_COMP("P06AT501", "VirtAcctMultiMchntPreAuthCompleteService", "多商户预授权完成"),
    ;
    private String txnNum;
    private String service;
    private String desc;

    AcctTxnNumEnum(String txnNum, String service, String desc) {
        this.txnNum = txnNum;
        this.service = service;
        this.desc = desc;
    }

    public String getTxnNum() {
        return txnNum;
    }

    public String getService() {
        return service;
    }

    public String getDesc() {
        return desc;
    }

    public static AcctTxnNumEnum getInstance(String txnNum) {
        switch (txnNum) {
            case "M00AT001":
                return ESTABLISH;
            case "T00AT001":
                return BALANCE_QUERY;
            case "T00AT002":
                return TRANS_DETAIL_QUERY;
            case "T00AT003":
                return SINGLE_TRANS_DETAIL;
            case "P06AT100":
                return PRE_AUTH;
            case "P06AT300":
                return PRE_AUTH_CANCEL;
            case "P06AT500":
                return PRE_AUTH_COMP;
            case "P01AT001":
                return SINGLE_ADJUST;
            case "M00AT002":
                return STATUS_CHANGE;
            case "P01AT002":
                return MULTI_MCHNT_ADJUST;
            case "T00AT004":
                return TRANS_STATUS_QUERY;
            case "P06AT101":
                return MULT_MCHNT_PRE_AUTH;
            case "P06AT301":
                return MULT_MCHNT_PRE_AUTH_CANCEL;
            case "P06AT501":
                return MULT_MCHNT_PRE_AUTH_COMP;
            default:
                return null;
        }
    }

    /**
     * 是否单笔交易
     *
     * @param txnNum
     * @return true是单笔交易；false多商户交易或者其他开户查询交易
     */
    public static boolean isSingle(String txnNum) {
        switch (txnNum) {
            case "P06AT100":
            case "P06AT300":
            case "P06AT500":
            case "P01AT001":
                return true;
            default:
                return false;
        }
    }

    /**
     * 是否多商户交易
     *
     * @param txnNum
     * @return true是多商户交易；false单笔交易或者其他开户、查询交易
     */
    public static boolean isMulti(String txnNum) {
        switch (txnNum) {
            case "P06AT101":
            case "P06AT301":
            case "P06AT501":
            case "P01AT002":
                return true;
            default:
                return false;
        }
    }

    /**
     * 是否预授权包括单笔预授权和多商户预授权（非预授权撤销、预授权完成、多商户预授权撤销、多商户预授权完成）
     *
     * @param txnNum
     * @return true是预授权包括单笔预授权和多商户预授权；false其他交易
     */
    public static boolean isPreAuth(String txnNum) {
        switch (txnNum) {
            case "P06AT101":
            case "P06AT100":
                return true;
            default:
                return false;
        }
    }
}
